package org.gy.T8;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

public class FileInputStreamTest3 {
    public static void main(String[] args) throws Exception{
        // 1、⼀次性读取完⽂件的全部字节到⼀个字节数组中去。
// 创建⼀个字节输⼊流管道与源⽂件接通
        InputStream is = new FileInputStream("C:/file-io-app\\src\\itheima03.txt");
// 2、准备⼀个字节数组，⼤⼩与⽂件的⼤⼩正好⼀样⼤。
        File f = new File("C:/file-io-app\\src\\itheima03.txt");
        long size = f.length();
        byte[] buffer = new byte[(int) size];
        int len = is.read(buffer);
        System.out.println(new String(buffer));
//3、关闭流
        is.close();
    }
}
